package cn.teduymdj.jxc.redisTests;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

import java.io.Serializable;
import java.time.LocalDateTime;

@Slf4j
@SpringBootTest
public class RedisTsets {
    @Autowired
    RedisTemplate<String, Serializable> redisTemplate;
    @Test
    public void test01(){
            String key = "username1";
            ValueOperations<String, Serializable> ops = redisTemplate.opsForValue();
            Serializable serializable = ops.get(key);
            log.debug(serializable+"");
    }
    @Test
    public void test02(){
        ValueOperations<String, Serializable> ops = redisTemplate.opsForValue();
        Serializable o = (Serializable)JSON.toJSON(LocalDateTime.now());
        ops.set("时间", o);
    }
}
